package com.example.idlefish.MyAccount.contract


import android.app.Activity
import android.content.Context
import android.content.Intent
import androidx.activity.result.contract.ActivityResultContract
import com.example.idlefish.MyAccount.contract.*
import com.example.idlefish.MyAccount.activity.*
import com.example.idlefish.MyAccount.pojo.*

class RegisterContract : ActivityResultContract<String, User?>() {
    override fun createIntent(context: Context, input: String): Intent {
        return Intent(context, RegisterActivity::class.java).apply {
            putExtra("name", input)
        }
    }

    override fun parseResult(resultCode: Int, intent: Intent?): User? {
        if(intent == null)
        {
            return null
        }
        val data = CommonUtil.getSerializable(intent, "addInfo", User::class.java)
        if(resultCode == Activity.RESULT_OK){
            return data
        }
        return null
    }
}
